//
//  LYPersonalTopView.swift
//  LYOnlineBanking
//
//  Created by 李永彬 on 2025/8/1.
//

import UIKit

import UIKit

class LYPersonalTopView: UIView {
    
    lazy var backgroundImageView: UIImageView = {
        let iv = UIImageView()
        iv.contentMode = .scaleAspectFit
        iv.clipsToBounds = false
        iv.image = UIImage(named: "personal_top_bg")
        return iv
    }()
    
    private lazy var iconImgView: UIImageView = {
        let iv = UIImageView()
        iv.contentMode = .scaleAspectFit
        iv.clipsToBounds = true
        iv.image = UIImage(named: "product_top_icon")
        return iv
    }()
    
    private lazy var contentLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 12)
        label.textAlignment = .left
        label.numberOfLines = 0
        label.textColor = UIColor(hex: "#FFFFFF")
        label.text = LYlocalizedString("Adopt advanced")
        return label
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        commonInitSubviews()
    }
    
    func commonInitSubviews() {
        addSubview(backgroundImageView)
        addSubview(iconImgView)
        addSubview(contentLabel)
        layoutSubviewsConstraints()
    }
    
    func layoutSubviewsConstraints() {
        backgroundImageView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        iconImgView.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
//            make.width.equalTo(iconImgView.snp.height)
        }
 
        contentLabel.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(15)
            make.trailing.equalTo(iconImgView.snp.leading).offset(-5)
            make.centerY.equalToSuperview()
            make.bottom.lessThanOrEqualToSuperview().offset(-5)
        }
    }
 
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
